import { DefendSkillPropListPanel } from "../defend/DefendSkillPropListPanel";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { ObjCreate } from "../../common/ObjCreate";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { TweenMax } from "../../../../../com/greensock/TweenMax";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
//class CrossDefenceCopyMenuBase
    
    export  class CrossDefenceCopyMenuBase extends DefendSkillPropListPanel
    {
        constructor(arg1: Array<any>, arg2: string, arg3: string, arg4: Class, arg5: Boolean=false, arg6: string="", arg7: string="")
        {
            super(_skillMaxNum, arg5, arg6, arg7);
            this._buildingImgs = arg1;
            _skillMaxNum = this._buildingImgs.length;
            this._titleName = arg2;
            this._iconName = arg3;
            this._tipsClass = arg4;
            _skillBgNoSkillWidth = 16;
            _skillSlotWidth = 41;
            _skillDefaultNum = 5;
            _skillBgNoSkillWidth = 16;
            _skillSlotWidth = 41;
            _skillDefaultNum = 5;
            return;
        }

        public clean(): void
        {
            var loc2=null;
            var loc1=0;
            while (!(this._items == null) && loc1 < this._items.length) 
            {
                loc2 = this._items[loc1] as Object /* flash.display.DisplayObject */;
                DisplayUtil.removeMe(loc2);
                ++loc1;
            }
            this._items = null;
            this._buildingImgs = null;
            return;
        }

        public setNoMove(): void
        {
            DisplayUtil.removeMe(_moveBtn);
            return;
        }

        public get bg(): Object /* flash.display.Bitmap */
        {
            return this._bg;
        }

        public /* override */ setPropListData(arg1: Array<any>): void
        {
            return;
        }

        protected /* override */ createChildren(): void
        {
            _container = new Object /* flash.display.Sprite */();
            _container.x = 8;
            _container.y = 27;
            this.addChild(_container);
            LoaderManager.instance.load("CrossTowerMenuBg.png", this.onPropListBgLoaded);
            LoaderManager.instance.load(this._titleName, this.titleLoaded);
            _moveBtn = ObjCreate.createGButton("", 223, 1, 24, 22, this, "MoveBtn2");
            _moveBtn.x = this.width - 25;
            _moveBtn.toolTipData = HTMLUtil.addColor(Language.getString(60053), "#FFFFFF");
            _moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, onMoveBtnMouseDown);
            return;
        }

        protected /* override */ initShowHideBtn(): void
        {
            if (!_needHideBtn) 
            {
                return;
            }
            if (_btnHide != null) 
            {
                DisplayUtil.removeMe(_btnHide);
            }
            _btnHide = GlobalClass.getInstance("showBtn");
            _btnHide.x = this.width - 38;
            _btnHide.y = 12;
            _btnHide.rotationZ = 90;
            _btnHide.scaleX = -0.8;
            _btnHide.scaleY = 0.9;
            this.addChild(_btnHide);
            _btnHide.addEventListener(flash.events.MouseEvent.CLICK, this.clickHideHandler);
            hideShowOpComplete();
            return;
        }

        protected /* override */ hideBody(): void
        {
            if (!_needHideBtn) 
            {
                return;
            }
            _tweening = true;
            TweenMax.to(_container, _hideTweeingTime, {"scaleY": 0, "onComplete": hideShowOpComplete});
            TweenMax.to(this._bg, _hideTweeingTime, {"height": 20});
            return;
        }

        protected /* override */ showBody(): void
        {
            if (!_needHideBtn) 
            {
                return;
            }
            _tweening = true;
            TweenMax.to(_container, _hideTweeingTime, {"scaleY": 1, "onComplete": hideShowOpComplete});
            TweenMax.to(this._bg, _hideTweeingTime, {"height": 71});
            return;
        }

        protected /* override */ clickHideHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!_needHideBtn) 
            {
                return;
            }
            if (_tweening) 
            {
                return;
            }
            if (_btnHide.scaleX != -0.8) 
            {
                _btnHide.scaleX = -0.8;
                this.showBody();
            }
            else 
            {
                _btnHide.scaleX = 0.8;
                this.hideBody();
            }
            _btnHide.scaleY = 0.9;
            return;
        }

        protected /* override */ onPropListBgLoaded(arg1: ImageInfo): void
        {
            this._bg = new ScaleBitmap(arg1.bitmapData.clone());
            this._bg.scale9Grid = new Object /* flash.geom.Rectangle */(6, 23, 75, 46);
            this._bg.width = this.width;
            this._bg.height = 71;
            this.addChildAt(this._bg, 0);
            return;
        }

        protected titleLoaded(arg1: ImageInfo): void
        {
            var loc1=null;
            loc1 = new Object /* flash.display.Bitmap */(arg1.bitmapData);
            loc1.x = (this.width - arg1.bitmapData.width) / 2;
            loc1.y = 3;
            this.addChild(loc1);
            return;
        }

        public /* override */ get width(): number
        {
            var loc1=16 + _skillMaxNum * _skillSlotWidth;
            if (loc1 < 173) 
            {
                loc1 = 173;
            }
            return loc1;
        }

        protected iconLoaded(arg1: ImageInfo): void
        {
            var loc1=new Object /* flash.display.Bitmap */(arg1.bitmapData);
            loc1.y = 60;
            this.addChild(loc1);
            return;
        }

        protected onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            var loc1=arg1.currentTarget as Object /* flash.display.DisplayObject */;
            ToolTipsManager.register(loc1, this._tipsClass, loc1["data"]);
            loc1.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.onRemoved);
            return;
        }

        protected onRemoved(arg1: Object /* flash.events.Event */): void
        {
            var loc1=arg1.currentTarget as Object /* flash.display.DisplayObject */;
            loc1.removeEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.onRemoved);
            ToolTipsManager.unregister(loc1);
            return;
        }

        protected /* var */_buildingImgs: Array<any>;

        protected /* var */_items: Array<any>;

        protected /* var */_titleName: string;

        protected /* var */_iconName: string;

        protected /* var */_bg: Object /* flash.display.Bitmap */;

        protected /* var */_tipsClass: Class;
    }
